package net.ddns.xcyyds.kungfu.procedures;

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.Entity;
import net.minecraft.network.chat.TextComponent;

import net.ddns.xcyyds.kungfu.network.KungFuModVariables;

public class RLLearnBookProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
		if (entity == null)
			return;
		if ((entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null)
				.orElse(new KungFuModVariables.PlayerVariables())).oneHandJianRL) {
			if (entity instanceof Player _player && !_player.level.isClientSide())
				_player.displayClientMessage(new TextComponent("\u4F60\u5DF2\u7ECF\u5B66\u8FC7\u8BE5\u5251\u6CD5\u4E86\uFF01"), (false));
		} else {
			{
				boolean _setval = true;
				entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
					capability.oneHandJianRL = _setval;
					capability.syncPlayerVariables(entity);
				});
			}
			if (entity instanceof Player _player && !_player.level.isClientSide())
				_player.displayClientMessage(new TextComponent("\u4F60\u5DF2\u5B66\u4E60\uFF1A\u64A9\u5251\u5F0F\uFF01"), (false));
			if (entity instanceof Player _player && !_player.level.isClientSide())
				_player.displayClientMessage(new TextComponent("\u91CA\u653E\u65B9\u5F0F\uFF1ARL"), (false));
			ForSoundProcedure.execute(world, x, y, z);
			SoundProcedure.execute(world, x, y, z, 1f, 1.5f);
		}
	}
}
